package com.bxx.ermall.mapper;

import com.bxx.ermall.common.dto.CommentDto;
import com.bxx.ermall.entity.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author buxiaoxing
 * @since 2021-02-02
 */
public interface CommentMapper extends BaseMapper<Comment> {

    @Select("SELECT `comment`.*,goods.title,goods.cover_img,member.user_name,member.avatar from `comment`,goods,member where `comment`.goods_id=goods.id and `comment`.author = member.id and goods.`owner`=#{id}")
    List<CommentDto> getGoodsComment(Integer id);

    @Select("SELECT `comment`.*,goods.title,goods.cover_img,member.user_name,member.avatar from `comment`,goods,member where `comment`.goods_id=goods.id and `comment`.author = member.id and `comment`.`author`=#{id}")
    List<CommentDto> getUserComment(Integer id);
}
